<template>
  <!-- 组件是可以改的 -->
  <div>
    <!-- @change="changeVal" -->
    <el-select v-model="value" placeholder="请选择" size="small" @change="changeVal">
      <el-option v-for="item in list" :key="item.value" :label="item.label" :value="item.value"></el-option>
    </el-select>
  </div>
</template>

<script>
export default {
  // options写死的
  props: {
    options: {
      type: Object,
      default: undefined
    }
  },
  data() {
    return {
      value: "",
      list: []
    };
  },
  watch: {
    options(nv) {
      console.log(nv.data.xData, "我是传过来的数据源");
      let list = nv.data.xData.forEach((item, index) => {
        this.$set(this.list, index, { label: item, value: index });
      });
    }
  },
  methods: {
    changeVal() {
      console.log(this.value);
      this.$emit("changeValAction", this.value);
    }
  }
};
</script>

<style>
</style>